package com.handpay.zztong.hp.trans.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.handpay.framework.utils.CommonUtils;
import com.handpay.framework.utils.DateUtils;
import com.handpay.zztong.hp.R;
import com.handpay.zztong.hp.base.activity.ZZTongActivity;
import com.handpay.zztong.hp.bean.ActionBar;
import com.handpay.zztong.hp.paymentbill.model.Bill;
import com.handpay.zztong.hp.paymentbill.activity.QueryBillsActivity;
import com.handpay.zztong.hp.utils.AccountUtils;
/*
    四要素验证失败
*/
public class TransResultFourElementsFailureActivity extends ZZTongActivity implements View.OnClickListener {

    private TextView businessInfo;
    private TextView transType;
    private TextView transSn;
    private TextView transTime;
    private TextView ConsumerCard;
    private TextView ConsumerTotal;
    private TextView transFailure;

    @Override
    protected boolean isShownTabs() {
        return false;
    }

    @Override
    public ActionBar getActivityActionBar() {
        //leftBar goBack();
        return new ActionBar(this.getString(R.string.trans_details), true);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        this.setContentView(R.layout.activity_trans_result_four_elements);
        super.onCreate(savedInstanceState);
        businessInfo = (TextView) findViewById(R.id.businessInfotv);
        transType = (TextView) findViewById(R.id.transType);
        transSn = (TextView) findViewById(R.id.transSn);
        transTime = (TextView) findViewById(R.id.transTime);
        ConsumerCard = (TextView) findViewById(R.id.consumerCard);
        ConsumerTotal = (TextView) findViewById(R.id.transtotal);
        transFailure = (TextView) findViewById(R.id.transfailuretv);

        myActionBar.setTitleTextSize(20);

        Intent intent = getIntent();
        Bill bill = (Bill) intent.getSerializableExtra(QueryBillsActivity.billvalue);
        this.businessInfo.setText(AccountUtils.getShopName(this));
        this.transType.setText(R.string.account_transfer);
        this.transSn.setText(bill.getTransSN());
        this.transTime.setText(DateUtils.formatDateToString(DateUtils.formatStringToDate(bill.getTransTime(), "yyyyMMddHHmmss"), "yyyy-MM-dd HH:mm:ss"));
        if (TextUtils.isEmpty(bill.getTranMediaType())) {
            this.ConsumerCard.setText(bill.getCardNoOut());
        } else {
            this.ConsumerCard.setText(bill.getCardNoOut() + " /" + bill.getTranMediaType());
        }
        this.ConsumerTotal.setText(CommonUtils.formatMoney(bill.getAmount() / 100));
        this.transFailure.setText(bill.getTransStatus());
        if (Bill.STATUS_PROCESSING == bill.getStatus()) {
            findViewById(R.id.failure_iv).setVisibility(View.GONE);
            findViewById(R.id.details_table).setVisibility(View.GONE);
            findViewById(R.id.details).setVisibility(View.VISIBLE);
            ((TextView) findViewById(R.id.details)).setText(bill.getTransStatus());
        }
    }

}
